<?php

class Form_InstallmentForm extends Form_Custom_General {

    public function init() {
        $ins_id = $this->createElement('hidden', 'ins_id')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($ins_id);


        $ins_ln_id = $this->createElement('select', 'ins_ln_id')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select loan")));
        $this->addElement($ins_ln_id);


        $ins_cus_id = $this->createElement('select', 'ins_cus_id')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select customer")));
        $this->addElement($ins_cus_id);



        $digitValidator = new Zend_Validate_Float();
        $digitValidator->setMessage('Please enter valid amount.');
        $ins_amount = $this->createElement('text', 'ins_amount')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter amount")))
                ->addValidator($digitValidator, true)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6", "placeholder" => "Amount"));
        $this->addElement($ins_amount);

        $ins_creditdate = $this->createElement('text', 'ins_creditdate')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select credit date")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6 datepicker", "placeholder" => "Credit date", 'readonly' => true));
        $this->addElement($ins_creditdate);

        $ins_uptodate = $this->createElement('text', 'ins_uptodate')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select uptil date")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "class" => "span6 datepicker", "placeholder" => "Uptil date", 'readonly' => true));
        $this->addElement($ins_uptodate);

        $ins_note = $this->createElement('textarea', 'ins_note')
                #->setRequired(TRUE)
                #->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please enter enddate")))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60", "rows" => "3", "cols" => "10", "class" => "span6", "placeholder" => "Note"));
        $this->addElement($ins_note);


        $ins_status = $this->createElement('select', 'ins_status')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => "Please select status")));
        $this->addElement($ins_status);

        $submit = $this->createElement('submit', 'Save')
                ->setAttribs(Array('title' => "Save changes", 'class' => "btn-glow primary"));
        $this->addElement($submit);

        $reset = $this->createElement('reset', 'Reset')
                ->setAttribs(Array('title' => "Reset changes", 'class' => "btn-glow primary"));
        $this->addElement($reset);
    }

}